package com.google.code.mochaccino.framework.hibernate;
/*
 * Copyright 2012 Claude Houle claude.houle@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;

/**
 * Generic DAO Interface
 *
 * @param <T> The Entity Type
 */
public interface DAO<T> {

	/** Get the Number of entities */
	long count();

	/** Delete Entities */
	void delete( T... entities );

	/** Evict Specified Entity */
	void evict( T... entity );

	/** Find All Entities */
	List<T> findAll();

	/** Find All Entities */
	List<T> findAll( String [] joins );

	/** Get for id. */
	T get( Serializable id );

	/** Get for id. */
	T get( Serializable id, LockMode mode );

	/** Get for id. */
	T get( Serializable id, LockOptions mode );

	/** Get for id. */
	T getReference( Serializable id );

	/** Get Entity Class */
	Class<T> getType();

	/** Iterate */
	Iterator<T> iterateAll();

	/** Persist Entities */
	void persist( T... entities );

	/**
	 * Validate Entity. Note that is there is a validation exception, it will be thrown.
	 *
	 * @return true if the validation has proceeded. false if the validator could not be executed.
	 */
	boolean validate( T entity );
}